package com.greenDao.activity.add;

import android.os.Bundle;
import android.util.SparseIntArray;
import android.widget.EditText;
import android.widget.Spinner;

import com.greenDao.activity.R;
import com.greenDao.activity.tool.DatabaseUtils;
import com.greenDao.activity.tool.GuiUtils;
import com.greenDao.activity.tool.button.BackButton;
import com.greenDao.activity.tool.button.event.AddEventButton;

public final class AddEventActivity extends AbstractAddActivity {

	private final SparseIntArray positionToId = new SparseIntArray();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_add_event);

		EditText name = (EditText) findViewById(R.id.nameEdit);
		EditText date = (EditText) findViewById(R.id.dateEdit);
		EditText comment = (EditText) findViewById(R.id.commentEdit);
		Spinner spinner = (Spinner) findViewById(R.id.spinner);
		spinner.setAdapter(DatabaseUtils.createAdapter(this, positionToId));

		GuiUtils.hookButton(this, R.id.buttonBackAddEvent, new BackButton(this));
		GuiUtils.hookButton(this, R.id.buttonAddEvent, new AddEventButton(this, name, spinner, date, comment));
	}
}
